import { defineStore } from 'pinia'
import chatApi from '@/apis/chat'

export const useVisroleStore = defineStore('visrole', {
  state: () => ({
    categories: [],
    active: null,
  }),
  actions: {
    async getCategories() {
      this.categories = (await chatApi.category.list('visrole')).data
    },
    setActive(visrole) {
      this.active = visrole
    },
    displayStyle(style = '', defaultValue = 'list') {
      if (style) {
        localStorage.setItem('displayStyle', style)
      } else {
        return localStorage.getItem('displayStyle') || defaultValue
      }
    },
  },
})
